package day08;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public class homework01 {
    /*
     *方法引用练习：
     *1.集合中存储一些字符串的数据，比如:张三，23
     *收集到student 类型当中（方法引用完成）
     *预习：1.Arraylist底层原理
     *		2.hashmap的底层原理
     */
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, "张三,23", "李四,45", "王五,75", "刘六,24");
        List<Student> stu = list.stream().map(homework01::createstudent).collect(Collectors.toList());
        System.out.println(stu);
    }

    private static Student createstudent(String s) {
        String[] split = s.split(",");
        String name = split[0];
        int age = Integer.parseInt(split[1]);
        return new Student(name, age);
    }
}
